package com.lh.consume;

import com.sise.bean.AdminDTO;
import com.sise.bean.DeleteDTO;
import com.sise.service.AdminRpcService;
import com.sise.service.UserRpcService;
import com.sise.service.ValidationService;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.io.IOException;

/**
 * 作者：idea
 * 日期：2018/7/29
 * 描述：消费者测试
 */
public class ConsumerTest {

    private static void getUserService(ClassPathXmlApplicationContext context) throws InterruptedException {
        UserRpcService userRpcService= (UserRpcService) context.getBean("userRpcService");
        System.out.println(userRpcService.getUserName("this is "+1));
    }

    private static void getValidation(ClassPathXmlApplicationContext context){
        ValidationService validationService= (ValidationService) context.getBean("validationService");
        DeleteDTO result=validationService.delete(10);
        System.out.println(result.getId()+"****");
    }

    private static void getAdminRegister(ClassPathXmlApplicationContext context){
        AdminRpcService adminService= (AdminRpcService) context.getBean("adminService");
        AdminDTO adminDTO=new AdminDTO();
        adminDTO.setAge(11);
        adminDTO.setPassword("111");
        adminDTO.setUsername("username");
        adminService.register(adminDTO);
    }


    public static void main(String[] args) throws InterruptedException {
        ClassPathXmlApplicationContext context=new ClassPathXmlApplicationContext(
                new String[]{"classpath:application-consumer.xml"});
        context.start();
//        getAdminRegister(context);
        for(int i=0;i<100;i++){
            UserRpcService userRpcService= (UserRpcService) context.getBean("userRpcService");
            System.out.println(userRpcService.getUserName("idea"+i));
        }
        try {
            System.in.read();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
